package com.mr.web;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

/**
 * @ClassName LoginController
 * @Description: TODO
 * @Author kun
 * @Date 2020/8/26
 * @Version V1.0
 **/
@RestController
public class LoginController {

    //存session
    @GetMapping("login")
    public String Login(String username, String password, HttpSession session){
        if(username.equals("kunk") && password.equals("123231")){
            session.setAttribute("admin_user",username);
            return "ok";
        }
        return "no";
    }
    //取session
    @GetMapping("show")
    public String show(HttpSession session){
        if(session.getAttribute("admin_user") != null){
            return "这是 "+session.getAttribute("admin_user")+"登陆界面";
        }else {
            return "无用户登录"+session.getAttribute("admin_user");
        }

    }
}
